clear

use "C:\Users\scjung\Desktop\HavesHavenots\dta_nuclearnuclearizing_irap_replication.dta"

*Model 1
relogit midinitiate nuke_a nuclearizing_a nuke_b nuclearizing_b ///
trade2gdp1 trade2gdp2 polity_a polity_b allies powrat rival ///
border distance ///
cwpceyrs pceyrs2 pceyrs3, cluster(dyadid)

setx (nuke_a nuclearizing_a nuke_b nuclearizing_b allies border rival) 0 ///
(trade2gdp1 trade2gdp2 polity_a polity_b powrat distance cwpceyrs pceyrs2 pceyrs3) median

relogitq, rr(nuke_a 0 1 & nuclearizing_a 0 1 & nuke_b 0 1 & nuclearizing_b 0 1 & trade2gdp1 p25 p75 & polity_b p25 p75 & powrat p25 p75 & rival 0 1 & border 0 1 & distance p25 p75)

*Model 2
relogit midinitiatef nuke_a nuclearizing_a nuke_b nuclearizing_b ///
trade2gdp1 trade2gdp2 polity_a polity_b allies powrat rival ///
border distance ///
cwpceyrs pceyrs2 pceyrs3, cluster(dyadid)

setx (nuke_a nuclearizing_a nuke_b nuclearizing_b allies border rival) 0 ///
(trade2gdp1 trade2gdp2 polity_a polity_b powrat distance cwpceyrs pceyrs2 pceyrs3) median

relogitq, rr(nuke_a 0 1 & nuclearizing_a 0 1 & nuke_b 0 1 & allies 0 1 & rival 0 1 & border 0 1 & distance p25 p75)

*Model 3
relogit midinitiate nuke_nuclearizing nucle_nucle nonuke_nuclearizing  ///
trade2gdp1 trade2gdp2 polity_a polity_b allies powrat rival ///
border distance  ///
cwpceyrs pceyrs2 pceyrs3, cluster(dyadid)

setx (nuke_nuclearizing nucle_nucle nonuke_nuclearizing allies border rival) 0 ///
(trade2gdp1 trade2gdp2 polity_a polity_b powrat distance cwpceyrs pceyrs2 pceyrs3) median

relogitq, rr(nuke_nuclearizing 0 1 & nonuke_nuclearizing 0 1 & ///
trade2gdp1 p25 p75 & polity_b p25 p75 & ///
 powrat p25 p75 & rival 0 1 & border 0 1 & distance p25 p75)

*Model 4
relogit midinitiatef nuke_nuclearizing nucle_nucle nonuke_nuclearizing  ///
trade2gdp1 trade2gdp2 polity_a polity_b allies powrat rival ///
border distance  ///
cwpceyrs pceyrs2 pceyrs3, cluster(dyadid)

setx (nuke_nuclearizing nucle_nucle nonuke_nuclearizing allies border rival) 0 ///
(trade2gdp1 trade2gdp2 polity_a polity_b powrat distance cwpceyrs pceyrs2 pceyrs3) median

relogitq, rr(nuke_nuclearizing 0 1 & ///
allies 0 1 & rival 0 1 & border 0 1 & distance p25 p75) 
 
 
* Predicted Probabilities 

estsimp logit midinitiate nuke_nuclearizing nucle_nucle nonuke_nuclearizing trade2gdp1 trade2gdp2 polity_a polity_b allies powrat rival border distance  cwpceyrs pceyrs2 pceyrs3
setx nuke_nuclearizing 1 nucle_nucle 0 nonuke_nuclearizing 0 trade2gdp1 mean trade2gdp2 mean polity_a mean polity_b mean allies 0 rival 1 border 1 distance 704 cwpceyrs 10 pceyrs2 100 pceyrs3 1000
local a=1
while `a' <=10 {
local b=0.01+(`a'-1)*0.1
setx powrat `b'
simqi, prval(1)
local a=`a'+1
}

estsimp logit midinitiate nuke_a nuclearizing_a nuke_b nuclearizing_b trade2gdp1 trade2gdp2 polity_a polity_b allies powrat rival border distance  cwpceyrs pceyrs2 pceyrs3, dropsims
setx nuke_a 1 nuclearizing_a 0 nuke_b 0 nuclearizing_b 0 trade2gdp1 mean trade2gdp2 mean polity_a mean polity_b mean allies 0 rival 1 border 1 distance 704 cwpceyrs 10 pceyrs2 100 pceyrs3 1000
local a=1
while `a' <=10 {
local b=0.01+(`a'-1)*0.1
setx powrat `b'
simqi, prval(1)
local a=`a'+1
}

setx nuke_a 0 nuclearizing_a 1 nuke_b 0 nuclearizing_b 0 trade2gdp1 mean trade2gdp2 mean polity_a mean polity_b mean allies 0 rival 1 border 1 distance 704 cwpceyrs 10 pceyrs2 100 pceyrs3 1000
local a=1
while `a' <=10 {
local b=0.01+(`a'-1)*0.1
setx powrat `b'
simqi, prval(1)
local a=`a'+1
}

setx nuke_a 0 nuclearizing_a 0 nuke_b 0 nuclearizing_b 0 trade2gdp1 mean trade2gdp2 mean polity_a mean polity_b mean allies 0 rival 1 border 1 distance 704 cwpceyrs 10 pceyrs2 100 pceyrs3 1000

local a=1
while `a' <=10 {
local b=0.01+(`a'-1)*0.1
setx powrat `b'
simqi, prval(1)
local a=`a'+1
}



* Robust Checks - Time Lag

* Model 5 
relogit midinitiate_lag nuke_a nuclearizing_a nuke_b nuclearizing_b ///
 trade2gdp1 trade2gdp2 polity_a polity_b allies powrat rival ///
border distance ///
cwpceyrs pceyrs2 pceyrs3, cluster(dyadid)

setx (nuke_a nuclearizing_a nuke_b nuclearizing_b allies border rival) 0 ///
(trade2gdp1 trade2gdp2 polity_a polity_b powrat distance cwpceyrs pceyrs2 pceyrs3) median

relogitq, rr(nuke_a 0 1 & nuclearizing_a 0 1 & nuke_b 0 1 & nuclearizing_b 0 1 & trade2gdp1 p25 p75 & polity_b p25 p75 & powrat p25 p75 & rival 0 1 & border 0 1 & distance p25 p75)

*Model 6 - Time Lag
relogit midinitiate_lag nuke_nuclearizing nucle_nucle nonuke_nuclearizing  ///
 trade2gdp1 trade2gdp2 polity_a polity_b allies powrat rival ///
border distance  ///
cwpceyrs pceyrs2 pceyrs3, cluster(dyadid)

setx (nuke_nuclearizing nucle_nucle nonuke_nuclearizing allies border rival) 0 ///
(trade2gdp1 trade2gdp2 polity_a polity_b powrat distance cwpceyrs pceyrs2 pceyrs3) median

relogitq, rr(nuke_nuclearizing 0 1 & nonuke_nuclearizing 0 1 & ///
trade2gdp1 p25 p75 & polity_b p25 p75 & ///
 powrat p25 p75 & rival 0 1 & border 0 1 & distance p25 p75)


* Robust Checks 2 - Way & Weeks
 
*Model 7
relogit midinitiate_lag nuke_a_2w nuclearizing_a_2w nuke_b_2w nuclearizing_b_2w ///
 trade2gdp1 trade2gdp2 polity_a polity_b allies powrat rival ///
border distance ///
cwpceyrs pceyrs2 pceyrs3, cluster(dyadid)

setx (nuke_a_2w nuclearizing_a_2w nuke_b_2w nuclearizing_b_2w allies border rival) 0 ///
(trade2gdp1 trade2gdp2 polity_a polity_b powrat distance cwpceyrs pceyrs2 pceyrs3) median

relogitq, rr(nuke_a_2w 0 1 & nuclearizing_a_2w 0 1 & nuke_b_2w 0 1 & nuclearizing_b_2w 0 1 & trade2gdp1 p25 p75 & ///
polity_a p25 p75 & polity_b p25 p75 & powrat p25 p75 & rival 0 1 & border 0 1 & distance p25 p75)

*Model 8
relogit midinitiate_lag nuke_nuclearizing_2w nucle_nucle_2w nonuke_nuclearizing_2w  ///
 trade2gdp1 trade2gdp2 polity_a polity_b allies powrat rival ///
border distance  ///
cwpceyrs pceyrs2 pceyrs3, cluster(dyadid)

setx (nuke_nuclearizing_2w nucle_nucle_2w nonuke_nuclearizing_2w allies border rival) 0 ///
(trade2gdp1 trade2gdp2 polity_a polity_b powrat distance cwpceyrs pceyrs2 pceyrs3) median

relogitq, rr(nuke_nuclearizing_2w 0 1 & nucle_nucle_2w 0 1 & nonuke_nuclearizing_2w 0 1 & ///
trade2gdp1 p25 p75 & polity_b p25 p75 & ///
 powrat p25 p75 & rival 0 1 & border 0 1 & distance p25 p75)
 
*The end 
